NEKOPATH=/usr/lib/neko
CC=g++
HXCPP=`haxelib path hxcpp | head -1`
HXCPP_INCLUDE= $(HXCPP)/include

all : ubuntu_compile

ldd : 
	ldd -d -r ndll/kyototycoon.ndll

haxedoc :
	haxe -xml haxedoc.xml -neko Lib kt.RemoteDB

haxelib_prepare : haxedoc
	zip -r kyototycoon.zip . -i \*.cpp \*.hx \*.ndll changes LICENSE.txt \*.hxml Makefile \*.xml README ubuntu_kt_get haxedoc.xml

haxelib_test : haxelib_prepare
	haxelib test kyototycoon.zip 

ubuntu_compile :
	cd src
	export NEKOPATH=$(NEKOPATH)
	rm -f ndll/Linux/kyototycoon.ndll & \
	rm -f all_objs & \
	rm -rf obj
	mkdir obj
	mkdir obj/linux 
	mkdir obj/linux/src
	$(CC) -c -fvisibility=hidden -O2 -fpic -fPIC -DHX_LINUX -m32 `ktutilmgr conf -i` -I$(HXCPP_INCLUDE) -x c++ -frtti ./src/KTRemoteDB.cpp -oobj/linux//src/KTRemoteDB.o
	touch all_objs
	echo obj/linux//src/KTRemoteDB.o >> all_objs
	$(CC) `ktutilmgr conf -i` -shared -Iinclude  `ktutilmgr conf -l` -o ndll/Linux/kyototycoon.ndll -fpic -fPIC -m32 -W,l--unresolved-symbols=report-all @all_objs
	strip ndll/Linux/kyototycoon.ndll


ubuntu_compile_64 :
	cd src
	export NEKOPATH=$(NEKOPATH)
	rm -f ndll/Linux64/kyototycoon.ndll & \
	rm -f all_objs & \
	rm -rf obj
	mkdir obj
	mkdir obj/linux 
	mkdir obj/linux/src
	$(CC) -c -fvisibility=hidden -O2 -fpic -fPIC -DHX_LINUX -m64 `ktutilmgr conf -i` -I$(HXCPP_INCLUDE) -x c++ -frtti ./src/KTRemoteDB.cpp -oobj/linux//src/KTRemoteDB.o
	touch all_objs
	echo obj/linux//src/KTRemoteDB.o >> all_objs
	$(CC) `ktutilmgr conf -i` -shared -Iinclude  `ktutilmgr conf -l` -o ndll/Linux64/kyototycoon.ndll -fpic -fPIC -m64 -W,l--unresolved-symbols=report-all @all_objs
	strip ndll/Linux64/kyototycoon.ndll

ubuntu_get_kt :
	make -f ubuntu_get_kt
